
<?php
include_once 'functions/getUnwantedWordsArray.php';

function removeUnwantedWords($text) {
	$unwantedSymbolsArray = array(',',':','"','.' ,'!','"');
	$unwantedWordsArray = getUnwantedWordsArray();
		$filteredText = str_replace($unwantedSymbolsArray, " ", $text);
	foreach($unwantedWordsArray as $pattern){			
			$pattern = "/(^|\s)" . $pattern . "($|\s)/i";
			$filteredText = preg_replace($pattern, " ", $filteredText);
	}
	
	
	$filteredText = removeWhiteSpacesExcess($filteredText);
	$filteredText = ltrim($filteredText);
	return $filteredText;
}

function removeWhiteSpacesExcess($filteredText){
	
	$filteredText = preg_replace('/\s\s+/', ' ', $filteredText);
	return $filteredText;
	
}
?>
